package com.rockcent.mall.lib.repository;

import com.rockcent.common.common.PageResult;
import com.rockcent.common.domain.enumclass.Whether;
import com.rockcent.mall.lib.domain.MerchantOrder;
import com.rockcent.mall.lib.domain.enumclass.EvaluateStatus;
import com.rockcent.mall.lib.domain.enumclass.MerchantOrderSourceType;
import com.rockcent.mall.lib.domain.enumclass.OrderEventType;
import com.rockcent.mall.lib.domain.enumclass.OrderStatus;
import com.rockcent.mall.lib.dto.ChannelProductDto;
import com.rockcent.mall.lib.dto.MerchantOrderDto;

import java.util.List;

/**
 * Created by oyhk on 14-6-22.
 */
public interface MerchantOrderRepositoryCustom<T> {
    /**
     * @param merchantId
     * @param dto
     * @param pageResult
     * @return
     */
    PageResult<MerchantOrderDto> findMerchantOrderPage(Long merchantId, MerchantOrderDto dto, PageResult pageResult);

    /**
     * @param productId
     * @param merchantId
     * @param mallId
     * @param channelId
     * @return
     */
    Long countProductSaleByChannelId(Long productId, Long merchantId, Long mallId, Long channelId);

    /**
     * @param productId
     * @param merchantId
     * @param mallId
     * @param channelId
     * @return
     */
    Long countProductVerifyByChannelId(Long productId, Long merchantId, Long mallId, Long channelId);

    /**
     * @param customerId
     * @param orderStatusList
     * @param pageResult
     * @return
     */
    PageResult<MerchantOrderDto> findByCustomerIdAndStatusNotIn(Long customerId, List<String> orderStatusList, PageResult pageResult);

    /**
     * @param channelId
     * @param mallId
     * @param merchantId
     * @param type
     * @param typeId
     * @param orderSourceType
     * @param startDate
     * @param endDate
     * @return
     */
    Long countMerchantOrderByChannelIdAndMallIdAndMerchantId(Long channelId, Long mallId, Long merchantId, String type, Long typeId, MerchantOrderSourceType orderSourceType, String startDate, String endDate);

    /**
     * @param mallId
     * @param merchantId
     * @param type
     * @param typeId
     * @param orderSourceType
     * @param startDate
     * @param endDate
     * @return
     */
    Long countMerchantOrderByMallIdAndMerchantId(Long mallId, Long merchantId, String type, Long typeId, MerchantOrderSourceType orderSourceType, String startDate, String endDate);

    /**
     * @param customerId
     * @param orderType
     * @param status
     * @param evaluateStatus
     * @param isDelete
     * @param pageResult
     * @return
     */
    PageResult<MerchantOrderDto> findByCustomerIdPage(Long customerId, String orderType, String status, String evaluateStatus, Whether isDelete, PageResult pageResult);

    /**
     * @param customerId
     * @return
     */
    //计数待使用和部分使用的
    Integer countWaitUseAndPartUse(Long customerId);

    /**
     * @param mallId
     * @param merchantId
     * @param status
     * @param evaluateStatus
     * @return
     */
    Long getOrderStatisticsYesterDay(Long mallId, Long merchantId, OrderStatus status, EvaluateStatus evaluateStatus);

    /**
     * @param mallId
     * @param merchantId
     * @return
     */
    Long getOrderCustomerStatisticsYesterDay(Long mallId, Long merchantId);

    /**
     * @param mallId
     * @param merchantId
     * @return
     */
    Long getOrderProductStatisticsYesterDay(Long mallId, Long merchantId);

    /**
     * @param mallId
     * @param merchantId
     * @return
     */
    Double getOrderTotalSumStatisticsYesterDay(Long mallId, Long merchantId);

    /**
     * @param mallId
     * @param merchantId
     * @param status
     * @return
     */
    Long getPayOrderCustomerCountStatisticsYesterDay(Long mallId, Long merchantId, OrderEventType status);

    /**
     * @param mallId
     * @param merchantId
     * @param status
     * @return
     */
    Long getPayProductCountStatisticsYesterDay(Long mallId, Long merchantId, OrderEventType status);

    /**
     * @param mallId
     * @param merchantId
     * @param payed
     * @return
     */
    Double getPayOrderTotalStatisticsYesterDay(Long mallId, Long merchantId, OrderEventType payed);

    /**
     * @param mallId
     * @param dto
     * @param pageResult
     * @return
     */
    PageResult<MerchantOrder> findMallOrderPage(Long mallId, MerchantOrderDto dto, PageResult pageResult);

    /**
     * @return
     */
    List<MerchantOrder> queryAllPayedOrder();

    /**
     * @param mallId
     * @param merchantId
     * @param orderEventType
     * @return
     */
    Long getOrderNumStatisticsYesterDay(Long mallId, Long merchantId, OrderEventType orderEventType);


    /**
     * @param mallOrderId
     * @return
     */
    List<MerchantOrder> queryAllOrderOfWaitShopPickpup(Long mallOrderId);

    /**
     * @param mallOrderId
     * @return
     */
    List<MerchantOrder> queryAllOrderOfWaitShipped(Long mallOrderId);

    /**
     * @param mallOrderId
     * @return
     */
    List<MerchantOrder> queryAllOrderOfWaitStock(Long mallOrderId);

    /**
     * @return
     */
    List<Long> queryAllMallOrderIdsUnPickupAndExpired();

    /**
     * @return
     */
    List<Long> queryAllMallOrderIdsWaitShippedAndExpired();

    /**
     * @return
     */
    List<Long> queryAllMallOrderIdsWaitStockAndExpired();

    /**
     * @param mallId
     * @param mallOrderNum
     * @return
     */
    List<MerchantOrderDto> findMallBalanceAccountInfo(Long mallId, String mallOrderNum);

    /**
     * @param channelProductDto
     * @param pageResult
     * @return
     */
    PageResult<ChannelProductDto> findProductOrdersByProductNameAndChannelIdAndDate(ChannelProductDto channelProductDto, PageResult pageResult);

    /**
     * @param orderStatus
     * @param evaluateStatus
     * @return
     */
    List<MerchantOrder> findByStatusAndEvaluateStatus(OrderStatus orderStatus, EvaluateStatus evaluateStatus);

    /**
     * @param mallOrderId
     * @return
     */
    List<MerchantOrder> queryAllOrderOfWaitUse(Long mallOrderId);

    /**
     * @return
     */
    List<Long> queryAllMallOrderIdsWaitUseAndExpired();

    List<T> queryAllOrderOfExpired(Long mallOrderId, T t);

    PageResult<MerchantOrderDto> findByCustomerIdAndStatusIn(Long customerId, List<String> orderStatusList, PageResult pageResult);
}
